home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / taskbar.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  3KB  |  89 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import wx
  5. from gui.toolbox import to_icon
  6. from weakref import WeakValueDictionary
  7. from logging import getLogger
  8. log = getLogger('taskbar')
  9.  
  10. class DigsbyTaskBarIcon(wx.TaskBarIcon):
  11.     
  12.     def __init__(self, icon, menu = None, tooltip = None):
  13.         wx.TaskBarIcon.__init__(self)
  14.         if isinstance(icon, wx.WindowClass):
  15.             raise TypeError
  16.         
  17.         self._tooltip = ''
  18.         if icon is not None:
  19.             self.SetIcon(icon, tooltip)
  20.         
  21.         if menu is not None:
  22.             self.Menu = menu
  23.         
  24.         if 'wxMac' not in wx.PlatformInfo:
  25.             self.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnRightUp)
  26.         
  27.  
  28.     
  29.     def Destroy(self):
  30.         if getattr(self, '_icon_destroyed', False):
  31.             return log.critical('destroyed %r already. not destroying it again', self)
  32.         
  33.         log.info('Destroying %r', self)
  34.         self._icon_destroyed = True
  35.         wx.TaskBarIcon.Destroy(self)
  36.  
  37.     
  38.     def OnRightUp(self, e):
  39.         menu = self.CreatePopupMenu()
  40.         if menu is not None:
  41.             menu.PopupMenu()
  42.         
  43.  
  44.     
  45.     def CreatePopupMenu(self):
  46.         return self.Menu
  47.  
  48.     
  49.     def SetMenu(self, menu):
  50.         self._menu = menu
  51.         menu.Windowless = True
  52.  
  53.     
  54.     def GetMenu(self):
  55.         return getattr(self, '_menu', None)
  56.  
  57.     Menu = property(GetMenu, SetMenu)
  58.     
  59.     def SetIcon(self, icon_or_bitmap, tooltip = None):
  60.         size = self._IconSize
  61.         self._icon = to_icon(icon_or_bitmap.PIL.ResizedSmaller(size).ResizeCanvas(size, size))
  62.         if tooltip is None:
  63.             tooltip = self._tooltip
  64.         else:
  65.             self._tooltip = tooltip
  66.         wx.TaskBarIcon.SetIcon(self, self._icon, tooltip)
  67.  
  68.     
  69.     def GetIcon(self):
  70.         return self._icon
  71.  
  72.     Icon = property(GetIcon, SetIcon)
  73.     
  74.     def _IconSize(self):
  75.         size = 16
  76.         if 'wxMac' in wx.PlatformInfo:
  77.             size = 128
  78.         elif 'wxGTK' in wx.PlatformInfo:
  79.             get = wx.SystemSettings.GetMetric
  80.             size = get(wx.SYS_ICON_X)
  81.             size = 20
  82.         else:
  83.             get = wx.SystemSettings.GetMetric
  84.             size = get(wx.SYS_SMALLICON_X)
  85.         return size
  86.  
  87.     _IconSize = property(_IconSize)
  88.  
  89.